<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Class类的继承</title>
</head>
<body>
  
</body>
<script>
  function Animal() {
    this.eat = function() {
      console.log("吃东西");
    },
    this.sayName = function(name) {
      console.log("Animal_我的名字是：" + name);
    }
  }

  function Cat() {
    // Animal的this指向cat
    Animal.call(this) // 继承Animal
  }

  function Dog() {
    // Animal的this指向cat
    Animal.call(this), // 继承Animal
    this.sayName = function(name) {
      console.log("Dog_我的名字是：" + name);
    }
  }

  let cat = new Cat();
  cat.eat();
  cat.sayName("cat");

  
  let dog = new Dog();
  dog.eat();
  dog.sayName("dog");

</script>
</html>